Ext.define('PJ.view.trainingmanagement.DepartUserListTree', {
    extend: 'AM.default.DefaultTree',
    alias: ['widget.DepartUserListTree'],
    title: "组织机构树",
    
    initComponent: function(){
    	var me = this;
    	this.store = Ext.create('PJ.'+ prototype +'.unitregistrationmanagement.ChooseUserTree');
        var selectScopeId=$(document.getElementById("selectScope")).find("option:selected")[0].value;
    	this.addListener("itemclick", function(view, record, htmlelement, index, eventObject, object){
    		if(eventObject){
    			eventObject.stopEvent();
    		}
    		this.deptId=record.data.id;
    		if(this.deptId!=''){
    			var gridList = this.up("container").down("grid");
    			var gridListStore = gridList.getStore();
    			gridList.recordId = this.deptId;
    			gridList.store.isLoad = true;
    	    	this.up("container").depid=this.deptId;
    			var newParams = {
    					searchDepId: this.deptId,
    					//searchClassID: me.up('window').classId
    			};
    			var params = gridListStore.proxy.extraParams;
    			Ext.apply(params, newParams);
    			gridListStore.load();
    		}
    	});
		var treeStore = me.getStore();
		var u;
		u=treeStore.url2+"?depId="+selectScopeId;
//		if(me.clickSource==1){
//			u=treeStore.url;
//		}else{
//			u=treeStore.url;
//		}
		treeStore.setProxy({
			type: gj_onlineLearning_constant.loadType,
			url: u,
		});
		this.callParent(arguments);
		this.loadType = gj_onlineLearning_constant.loadType;
    },
    listeners: {
    	//显示树的一级菜单
            load: function(treeStore, node, records, successful, eOpts){
                if (records != null && node.hasChildNodes()) {
                    this.expandNode(records[0]);
                    isExp = false;
                }
            }
    }
});
